﻿namespace NTLib.Pipe.Containers
{
    using NTLib.Core.Pool;
    using NTLib.Pipe.Exceptions;
    using System;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.Linq;
    using System.Text;
    using System.Threading;
    using System.Threading.Tasks;

    /// <summary>
    /// Class used to give only access to the pipe in pop
    /// </summary>
    /// <typeparam name="T"></typeparam>
    internal class ReadOnlyPipe<T> : BasePipeRelay<T>
    {
        #region CTOR

        /// <summary>
        /// Initializes a new instance of the <see cref="ReadOnlyPipe{T}"/> class.
        /// </summary>
        public ReadOnlyPipe()
        {
            base.PipeType = PipeType.FromTarget;
        }

        #endregion

        #region Methods

        ///// <summary>
        ///// Push an item to the item's queue if the pipe permits it and wait that the item is well arrived on the other side.
        ///// </summary>
        ///// <param name="item"></param>
        ///// <param name="token">Tpken used to cancel the task that wait to items arrived on the other side.</param>
        ///// <returns>
        ///// Asynchronious task that permit to wait that the item arrived on the other side.
        ///// </returns>
        ///// <exception cref="PipeActionNotPermitsException">PushAsync</exception>
        //public override Task<U> PushAsync<U>(T item, CancellationToken token = default(CancellationToken))
        //{
        //    throw new PipeActionNotPermitsException(this.PipeType, "PushAsync");
        //}

        /// <summary>
        /// Send an item to the item's queue if the pipe permits it.
        /// Attention this method doesn't wait that the item achieved the other side.
        /// </summary>
        /// <param name="item">Item to send</param>
        /// <exception cref="PipeActionNotPermitsException">Send</exception>
        public override Task SendAsync(T item, CancellationToken token = default(CancellationToken))
        {
            throw new PipeActionNotPermitsException(this.PipeType, "Send");
        }

        #endregion
    }
}
